//package com.configuration;
//
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.orm.jpa.JpaTransactionManager;
//import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
//import org.springframework.orm.jpa.vendor.Database;
//import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
//import org.springframework.transaction.PlatformTransactionManager;
//
//import javax.persistence.EntityManagerFactory;
//import javax.sql.DataSource;
//
///**
// * Created by Arat.Wu on 2017/12/25.
// *
// * 添加后sql执行报错
// */
//@Configuration
//@EnableJpaRepositories(value = "com",
//        entityManagerFactoryRef = "writeEntityManagerFactory",
//        transactionManagerRef="writeTransactionManager")
//public class WriteDataSourceConfig {
//    @Autowired
//    JpaProperties jpaProperties;
//    @Autowired
//    @Qualifier("writeDataSource")
//    private DataSource writeDruidDataSource;
//    /**
//     * EntityManagerFactory类似于Hibernate的SessionFactory,mybatis的SqlSessionFactory
//     * 总之,在执行操作之前,我们总要获取一个EntityManager,这就类似于Hibernate的Session,
//     * mybatis的sqlSession.
//     * @return
//     */
//    @Bean(name = "writeEntityManagerFactory")
//    @Primary
//    public EntityManagerFactory writeEntityManagerFactory() {
//        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
//        LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
//        factory.setJpaVendorAdapter(vendorAdapter);
//        factory.setPackagesToScan("com");
//        factory.setDataSource(writeDruidDataSource);//数据源
//        factory.setJpaPropertyMap(jpaProperties.getProperties());
//        factory.afterPropertiesSet();//在完成了其它所有相关的配置加载以及属性设置后,才初始化
//        return factory.getObject();
//    }
//    /**
//     * 配置事物管理器
//     * @return
//     */
//    @Bean(name = "writeTransactionManager")
//    @Primary
//    public PlatformTransactionManager writeTransactionManager() {
//        JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
//        jpaTransactionManager.setEntityManagerFactory(this.writeEntityManagerFactory());
//        return jpaTransactionManager;
////        DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager();
////        dataSourceTransactionManager.setDataSource(writeDruidDataSource);
////        return dataSourceTransactionManager;
//    }
//}